package org.edu.modules.oa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.edu.modules.oa.entity.VeOaMeetAttenEntity;
import org.edu.modules.oa.mapper.IVeOaCheckMeetAnnounceMapper;
import org.edu.modules.oa.mapper.IVeOaCheckMeetAttenMapper;
import org.edu.modules.oa.service.IVeOaCheckMeetAttenService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@Service
public class VeOaCheckMeetAttenServiceImpl implements IVeOaCheckMeetAttenService {

    @Resource
    private IVeOaCheckMeetAttenMapper iVeOaCheckMeetAttenMapper;


    @Override
    //考勤查询-查询表格
    public HashMap<String, Object> showCheckMeetAtten(Integer page, Integer pageSize, VeOaMeetAttenEntity veOaMeetAttenEntity) {
        HashMap<String,Object> map = new HashMap<>();
        //创建分页的page
        IPage<VeOaMeetAttenEntity>checkMeetAttenPage = new Page<>(page,pageSize);
        //创建查询的条件，wrapper是条件综合器
        QueryWrapper<VeOaMeetAttenEntity>wrapper = new QueryWrapper<>();
        //前台传来的条件
        if(veOaMeetAttenEntity.getMeetName()!=null && veOaMeetAttenEntity.getMeetName()!=""){
            wrapper.like("meet_name",veOaMeetAttenEntity.getMeetName());
        }
        if(veOaMeetAttenEntity.getAttenName()!=null && veOaMeetAttenEntity.getAttenName()!=""){
            wrapper.like("atten_name",veOaMeetAttenEntity.getAttenName());
        }
        //mybatis plus的动态查询方法
        // 条件加上分页查询
        checkMeetAttenPage = iVeOaCheckMeetAttenMapper.selectPage(checkMeetAttenPage,wrapper);
        List<VeOaMeetAttenEntity>list = checkMeetAttenPage.getRecords();
        int count = iVeOaCheckMeetAttenMapper.selectCount(wrapper);
        // 把查出来的东西存到map里面去
        map.put("list",list);
        map.put("count",count);
        return map;
    }
}
